package zestaw1.scanner;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

/**
 * Author: Daniel Michalski
 * Date: 13.07.13
 */

public class Main {
    String s1 = "1 2 3";
    String s2 = "Jan Kowalski/1200\nA. Grabowski/1500";

    public Main() {
        Scanner scann1 = new Scanner(s1);
        int suma = 0;
        while (scann1.hasNextInt())
            suma += scann1.nextInt();
        System.out.println("Suma wynosi " + suma);

        List<Employee> list = new ArrayList<Employee>();
        Scanner scann2 = new Scanner(s2);
        while (scann2.hasNextLine()) {
            Scanner scann3 = new Scanner(scann2.nextLine()).useDelimiter("/");
            String name = scann3.next();
            double salary = scann3.nextDouble();
            list.add(new Employee(name, salary));
        }

        double value = 0;
        for (Employee emp : list) {
            value += emp.getSalary();
            System.out.println(emp);
        }
        System.out.println("Suma zarobków: " + value);
    }

    public static void main(String[] args) {
        new Main();
    }
}
